package Model;


import java.sql.DriverManager;
import java.sql.SQLException;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author sio
 */
public class Connect {
    public static java.sql.Connection con = null;

    public static java.sql.Connection open() {

        try {
            Class.forName("org.postgresql.Driver");
        } catch (ClassNotFoundException e) {
            System.out.println("Pilote mal installé ...");
        }
        try {
            con = DriverManager.getConnection("jdbc:postgresql://lucie/medecin", "abiai", "linux");
        } catch (SQLException e) {
            System.out.println("Erreur SQL;" + e);
        }
        return con;
    }
    public static java.sql.Connection get(){
        if (con == null){
            con = Connect.open();
        }
        return con;
    }
    public static void close(){
        try{
            con.close();
        }catch(SQLException e){
            System.out.println("Erreur SQL :" + e);
            
        }
    }
}
